package com.ruoyi.project.system.service.impl;

import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.project.system.domain.DtProduct;
import com.ruoyi.project.system.mapper.DtProductMapper;
import com.ruoyi.project.system.service.IDtProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 查询产品Service业务层处理
 */
@Service
public class DtProductServiceImpl implements IDtProductService {

    @Autowired
    private DtProductMapper dtProductMapper;

    @Override
    public AjaxResult choiceItem() {
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.put("product", dtProductMapper.productChoice());
        long userId = SecurityUtils.getUserId();
        if (userId == 1) {
            ajaxResult.put("user", dtProductMapper.userChoice());
        }
        return ajaxResult;
    }

    /**
     * 查询查询产品
     *
     * @param id 查询产品主键
     * @return 查询产品
     */
    @Override
    public DtProduct selectDtProductById(Integer id) {
        return dtProductMapper.selectDtProductById(id);
    }


    @Override
    public List<DtProduct> selectDtProductList() {
        return dtProductMapper.selectDtProductList();
    }


}
